import { Service } from 'egg';

/**
 * 公共 Service
 */
export default class common extends Service {
  /**
  * 进行鉴权
  * @param userID ,name
  */
  public async check(_userID, _name) {
    const { app, ctx } = this;
    let req = await app.mysql.query('SELECT id,name FROM `user` WHERE `name` =?', [_name])
    if (req.length) {
      if (ctx.helper.Jsonsql(req)[0].id == _userID && ctx.helper.Jsonsql(req)[0].name == _name) {
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
  }
}

